import android.content.Context
import android.database.sqlite.SQLiteDatabase
import android.database.sqlite.SQLiteOpenHelper
import android.widget.Toast

class DiaryDbHelper(val context: Context?, name: String, version: Int):
    SQLiteOpenHelper(context, name, null, version)  {

    private val createDaily = "create table diary (" +
            "id integer primary key autoincrement," +
            "title text," +
            "description text)"

    override fun onCreate(diarydb: SQLiteDatabase) {
        diarydb.execSQL(createDaily)
        Toast.makeText(context, "Create succeeded", Toast.LENGTH_SHORT).show()
    }

    override fun onUpgrade(diarydb: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
        diarydb.execSQL("drop table if exists diary")
        onCreate(diarydb)
    }

}